/*
 * jQuery Plugin : jConfirmAction

 * 
 * by Hidayat Sagita
 * http://www.webstuffshare.com
 * Licensed Under GPL version 2 license.
 *
 */


			
$(document).ready(function() {
	
	
	$('.ask-plain').click(function(e) {
		
		e.preventDefault();
		thisHref	= $(this).attr('href');
		
		if(confirm('Are you sure')) {
			window.location = thisHref;
		}
		
	});
	
	$('.ask-custom').jConfirmAction({question : $(this).attr('title'), yesAnswer : "Ya", cancelAnswer : "Tidak"});
	$('.ask').jConfirmAction();
	
	$('label').click(function() {
		$('#container').append('<a class="ask">aaaaaa</a><br/>');
	});
	$("#currentVote").attr("class","active");
});

(function($){

	jQuery.fn.jConfirmAction = function (options) {
		
		// Some jConfirmAction options (limited to customize language) :
		// question : a text for your question.
		// yesAnswer : a text for Yes answer.
		// cancelAnswer : a text for Cancel/No answer.
		var theOptions = jQuery.extend ({
			question: "你确定删除吗 ?",
			yesAnswer: "确定",
			cancelAnswer: "取消"
		}, options);
		
		return this.each (function () {
			
			$(this).bind('click', function(e) {
				
				/*
				 * 
				 */
				
				$(".question").remove();
				e.preventDefault();
				thisHref	= $(this).attr('href');
				
				if($(this).next('.question').length <= 0)
					$(this).after('<div class="question">'+theOptions.question+'<br/> <span class="yes">'+theOptions.yesAnswer+'</span><span class="cancel">'+theOptions.cancelAnswer+'</span></div>');
				
				$(this).next('.question').animate({opacity: 1}, 300);
				
				$('.yes').bind('click', function(){
					window.location = thisHref;
				});
		
				$('.cancel').bind('click', function(){
					$(this).parents('.question').fadeOut(300, function() {
						$(this).remove();
					});
				});
				
			});
			
		});
	}
	
})(jQuery);